<style type="text/css">
.storelogo img{width:3.2rem;height:3.2rem}
.merchgroup .store-star {padding:0.1rem 0 0.2rem 0;font-size:0.55rem;line-height:1rem}
.merchgroup .store-star img{height:0.66rem}
.star-on,.star-off{position:absolute;top:1rem;left:0;overflow:hidden}
.star-rate {margin-left:3.6rem}
.store-distance{float:right;color:#999}
.store-moneylimit{font-size:0.55rem}
.jyui_cell_col .colchecked{background:{{main.syscolor||'#cdab6a'}};}
.weui_cells_radio .weui_check:checked + .weui_icon_checked:before {;
  color: {{main.syscolor||'#cdab6a'}};
}
.weui_cells_radio2 .weui_check:checked + .weui_icon_checked:before {
  color: {{main.syscolor||'#cdab6a'}};
}
.weui_cells_radio3 .weui_check:checked + .weui_icon_checked:before {
    color: {{main.syscolor||'#cdab6a'}};
}
.yuyue-duan {border: 1px solid #aaa;width:auto}
.pass {background:#449d44;}
.timescheck {border: 1px solid {{main.syscolor||'#cdab6a'}};background-color: {{main.syscolor||'#cdab6a'}};}
.bantimescheck {color:#fff;background-color: {{main.syscolor||'#cdab6a'}};}
.isyuyue {background:#aaa;}
.weui_btn_primary {
  background-color: {{main.syscolor||'#cdab6a'}};
}
.jylabels {
	line-height:1.6; 
}
.checkcol{background-color: {{main.syscolor||'#cdab6a'}};color:#fff}
.fui-icon-group .fui-icon-col2 {
    width: 50%;
    height: auto;
    position: relative;
    padding: 0;
    margin: 10px 0;
    text-align: center;
    transition: background-color 300ms;
    -webkit-transition: background-color 300ms;
    float: left;
}
</style>
<div class="fui-page order-create-page fui-page-current" ng-if="pagedata.op == 'list'">
	<div class="fui-content">
		<div id="carousel-container" class="carousel slide" data-role="carousel" data-param-auto="true">
			<div class="carousel-inner" role="listbox" style="height:6rem">
			<div ng-class="{'item':1,'active':$index==0}" ng-repeat="item in pagedata.pluginset.hdps">
				<a href="#">
					<img src="{{tomedia(item.picurl) || '../core/resource/images/banner-1.jpg'}}" style="display: block; width: 100%; height: 100%;">
				</a>
			</div>
			</div>
			<style>
					.fui-swipe-page .fui-swipe-bullet {background: {background}; opacity: {opacity};}
					.fui-swipe-page .fui-swipe-bullet.active {opacity: 1;}
			</style>
			<div id="carousel-jinyun" class="fui-swipe-page" style="padding: 0 5px; bottom: 10px; ">
				<div class="fui-swipe-bullet" ng-repeat="item in pagedata.pluginset.hdps" ng-class="{'active':$index==0}" data-target="#carousel-container" data-slide-to="{{$index}}"></div>
			</div>
		</div>
		<div class="fui-list-group merchgroup" style="margin-top:0" ng-repeat="item in pagedata.serve_list">
            <div class="fui-list">
                <a class="fui-list-media storelogo" href="javascript:;" ng-click="access_json('jy_qiuyuyue/server/sever_detail/id='+item.serve_id)">
                    <img class="round" ng-src="{{tomedia(item.image) || '../core/resource/images/nopic.jpg'}}">
                </a>
                <a class="fui-list-inner" style="margin-top:0.16rem" href="javascript:;" ng-click="access_json('jy_qiuyuyue/server/sever_detail/id='+item.serve_id)">
                    <div class="title" style="font-size:0.76rem">{{item.title}}</div>
                    <div class="store-star">
						<span class="star-on"> <img src="../core/resource/images/star-off.png"></span>
						<span class="star-off" style="width: 88%;"> <img src="../core/resource/images/star-on.png"></span>
						<span class="star-rate">4.5</span>
						<span ng-show="item.num">服务{{item.num}}个客户</span>
					</div>
					<div class="subtitle" style="font-size:0.55rem">
						<div class="store-moneylimit">
						  <span>人均¥{{item.price}}</span>
						  <span class="store-distance"> 服务时间：约{{item.times}}分钟</span>
						</div>
					</div>
                </a>
            </div>
		</div>
		<div ng-show="loading" class='infinite-loading'><span class='fui-preloader'></span><span style="margin-left:1.5rem"> 正在加载...</span></div>
	</div>
	<div ng-include="sys_html('_footer')"></div>
</div>
<div class="fui-page order-create-page fui-page-current" ng-if="pagedata.op == 'sever_detail'">
	<div class="fui-header">
		<div class="fui-header-left" ng-click="goback()">
            <a class="back"></a>
        </div>
		<div class="title">{{pagedata.serve.title}}</div>
		<div class="fui-header-right"></div>
	</div>
	<div class="fui-content">
		<div class="fui-cell-group" style="margin-top:0">
				<div class="fui-cell" style="padding-bottom:0">
					<div class="fui-cell-text">
						<div class="text" style="font-size:0.75rem"><i class="icon icon-shoucang"></i> {{pagedata.store.brandname || '无'}}({{pagedata.store.title}})</div>
						<div class="subtitle" style="font-size:0.55rem;padding-top:0.5rem">{{pagedata.store.address || '无地址'}},距离您{{pagedata.store.juli || 2.2}}km</div>
					</div>
					<div class="fui-cell-remark noremark">
						<a class="r-icon" href="tel:{{pagedata.store.tel || pagedata.store.mobile}}">
								<i class="icon icon-phone" style="padding:0.3rem;font-size:0.7rem"></i>
						</a>
						<span class="r-icon" style="margin-left:0.6rem" ng-click="pagedata.openLocation(pagedata.store);">
								<i class="icon icon-map" style="padding:0.3rem;font-size:0.7rem"></i>
						</span>
					</div>
				</div>
				<div class="fui-tab-scroll" style="background: #fff;overflow-y:hidden">
					<div ng-repeat="item in pagedata.data" ng-class="{'item':1,'on':pagedata.post.dayid==$index}" href="javascript:" ng-click="pagedata.post.dayid=$index;pagedata.getdata();">{{item.riqi}}({{item.xinq}})</div>
				</div>
				<div class="fui-cell" style="background: #e8fcf8;" ng-click="pagedata.showdingxieyi=true">
							<div class="fui-cell-text" style="color:#18bc9c">
								<div class="text" style="font-size:0.75rem"><i class="icon icon-xinxi"></i> {{pagedata.dingxieyi.title || '订/退场须知'}}</div>
							</div>
							<div class="fui-cell-remark">
							</div>
				</div>
		</div>
		<div class="row margin0" style="padding:0 0.5rem;">
			<div ng-class="{'jylabels jylabel-success':1,'active':pagedata.post.isye!=1}" ng-click="pagedata.post.isye=0;pagedata.getdata()">日场</div>
			<div ng-class="{'jylabels jylabel-success':1,'active':pagedata.post.isye==1}" ng-click="pagedata.post.isye=1;pagedata.getdata()">夜场</div>
		</div>
		<div class="fui-icon-group noborder col-3" style="background-color: #fff;">
					<div class="fui-icon-col external">
						<div class="text"><span style="background:#449d44;color:#449d44;border-radius:0.1rem;height:1rem;width:2rem">占位</span> 可选</div>
					</div>
					<div class="fui-icon-col external">
						<div class="text"><span class="sysbgcolor syscolor" style="border-radius:0.1rem;height:1rem;width:2rem">占位</span> 选中</div>
					</div>
					<div class="fui-icon-col external">
						<div class="text"><span style="background:#999;border-radius:0.1rem;color:#999;height:1rem;width:2rem">占位</span> 不可选</div>
					</div>
		</div>
		<div ng-if="pagedata.plate.length>0" class="fui-tab-scroll" style="padding-left:0.5rem;margin-top:-0.3rem">
				<div ng-repeat="item in pagedata.plate" ng-class="{'item':1,'on':pagedata.post.plate_id==item.id}" style="height:2rem;line-height:2rem"><a href="javascript:;" ng-click="pagedata.post.plate_id=item.id;pagedata.getdata()">{{item.title}}</a></div>
		</div>
		<div class="weui_cells_title" style="margin-top:0">请选择预约场次</div>
		<div ng-if="pagedata.pluginset.is_ban==1" class="fui-icon-group noborder col-2" style="margin:0.5rem 1rem;background:#aaa;border-radius:1rem;">
			<div ng-class="{'fui-icon-col':1, 'checkcol':pagedata.post.is_ban!=1}" ng-click="pagedata.post.is_ban=0;pagedata.getdata()" style="margin:0;padding:0.4rem 0">
				全场
			</div>
			<div ng-class="{'fui-icon-col':1, 'checkcol':pagedata.post.is_ban==1}" ng-click="pagedata.post.is_ban=1;pagedata.getdata()" class="fui-icon-col" style="margin:0;padding:0.4rem 0">
				半场
			</div>
		</div>
		<div ng-if="pagedata.post.is_ban!=1" class="weui_cells" style="margin-top:0">
			<div ng-repeat="row in pagedata.serve_time" ng-if="row.yuyue > 0 && row.show == 1 && row.ispass!=1" class="jy-3">
				<div ng-class="{'yuyue-duan pass':1,'timescheck':pagedata.post.timeids.indexOf(';'+row.id+';')>=0}" style="color:#fff" ng-click="pagedata.settime($index)">
					<div>{{row.times.start}}--{{row.times.end}}</div>
					<div ng-if="pagedata.serve.open_total==1">(可预约{{row.lastnum ||0}}人)</div>
					<div ng-if="pagedata.serve.open_total!=1">(￥{{price(row.fee)}})</div>
					<div class="clear"></div>
				</div>
			</div>
			<div ng-repeat="row in pagedata.serve_time" ng-if="(row.yuyue == 0 || row.show == 0) && row.ispass!=1" class="jy-3 disabled">
				<div class="yuyue-duan">
					<div>{{row.times.start}}--{{row.times.end}}</div>
					<div>({{row.show==0?'休息':'已订22'}})</div>
					<div class="clear"></div>
				</div>
			</div>
		</div>
		<div ng-if="pagedata.post.is_ban==1" class="weui_cells" style="margin-top:0;margin-bottom:0.5rem">
			<div ng-repeat="row in pagedata.serve_time" ng-if="row.yuyue==1 && row.show == 1 && row.ispass!=1" class="jy-2">
				<div class="c" style="margin-top:0.5rem">{{row.times.start}}--{{row.times.end}}</div>
				<div class="fui-icon-group noborder col-2 pass" style="margin:0 0.5rem;border-radius:1rem;color:#fff">
					<div ng-class="{'fui-icon-col2':1,'isyuyue':row.yuyue1==0,'bantimescheck':pagedata.post.timeids.indexOf(';'+row.id1+';')>=0}" ng-click="pagedata.settime($index,row.id1)" style="margin:0;padding:0.2rem 0;border-right: 2px solid #fff;">
						<div style="font-size:0.7rem">半场A</div>
						<div style="font-size:0.6rem">(￥{{price(row.fee)}})</div>
					</div>
					<div ng-class="{'fui-icon-col2':1,'isyuyue':row.yuyue1==0,'bantimescheck':pagedata.post.timeids.indexOf(';'+row.id2+';')>=0}" ng-click="pagedata.settime($index,row.id2)" class="fui-icon-col" style="margin:0;padding:0.2rem 0">
						<div style="font-size:0.7rem">半场B</div>
						<div style="font-size:0.6rem">(￥{{price(row.fee)}})</div>
					</div>
				</div>
			</div>
			<div ng-repeat="row in pagedata.serve_time" ng-if="(row.yuyue == 0 || row.show == 0) && row.ispass!=1" class="jy-2">
				<div class="c" style="margin-top:0.5rem">{{row.times.start}}--{{row.times.end}}</div>
				<div class="fui-icon-group noborder col-2 disabled" style="background:#aaa;margin:0 0.5rem;border-radius:1rem;color:#fff">
					<div class="fui-icon-col2" style="margin:0;padding:0.2rem 0;border-right: 2px solid #fff;">
						<div style="font-size:0.7rem">半场A</div>
						<div style="font-size:0.6rem">({{row.show==0?'休息':'已订'}})</div>
					</div>
					<div class="fui-icon-col2" class="fui-icon-col" style="margin:0;padding:0.2rem 0">
						<div style="font-size:0.7rem">半场B</div>
						<div style="font-size:0.6rem">({{row.show==0?'休息':'已订'}})</div>
					</div>
				</div>
			</div>
		</div>
		<div class="weui_cells_title" style="margin-top:0">已选择的场次</div>
		<div class="weui_cells" ng-if="pagedata.isselecttimes.length>0" style="margin-top:0">
			<div class="col-jy">
			<div ng-repeat="row in pagedata.isselecttimes" class="jy-3">
				<div class="yuyue-duan" style="background:#f60;color:#fff;border: 1px solid #f60;">
					<div>{{row.times.start}}--{{row.times.end}}</div>
					<div>{{row.is_ban==1?'半场'+row.selectid:'全场'}}</div>
					<div>(￥{{price(row.fee)}})</div>
					<div class="clear"></div>
				</div>
			</div>
			</div>
		</div>
	</div>
</div>
<div class="fui-navbar-tip" ng-click="pagedata.showdingxieyi=true">请仔细阅读《{{pagedata.dingxieyi.title || '订/退场须知'}}》</div>
<div class="fui-navbar order-create-checkout">
    <a href="javascript:;" class="nav-item total" style="text-align:left;padding-left:0.5rem">
        <span class="text-danger bigprice">&yen; 
			<span class="totalprice" style="font-size:1.2rem">{{pagedata.post.totalprice || '0.00'}}<span style="font-size:0.5rem">(场地费)</span></span>
		</span>
    </a>
    <a href="javascript:;" class="nav-item btn btn-danger buybtn" ng-click="pagedata.check_buy()">
		预订场地
	</a>
</div>
<div ng-if="pagedata.showdingxieyi" class="popup">
	<div class="popup-body">
		<div class="popup-center">
			<i class="closed icon icon-cuowu" style="font-size:1.2rem;top:105%;" ng-click="pagedata.showdingxieyi=false"></i>
			<div class="content-images" style="padding:0.5rem;height:20rem; overflow-y:scroll;">
					<div class="title bold" style="font-size:0.8rem">{{pagedata.dingxieyi.title || '订/退场须知'}} / <small>Read Ggree</small></div>
					<div class="text" style="padding-top:0.5rem;font-size:0.7rem" ng-bind-html="trust(pagedata.dingxieyi.content)">
					</div>
			</div>
			<div class="modal-footer">
				<div ng-click="pagedata.showdingxieyi=false;pagedata.item.check=1" class="mod-check" style="width: 100%; margin: 0;">我已阅读</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
scope.pagedata.get_store=function(lat,lng){
		var store_id=scope.pagedata.post.id
		scope.get('jy_qiuyuyue/server/get_store/lng='+lng+'&lat='+lat,function(res){
			scope.pagedata.store=res.store;
			scope.$evalAsync();
		});
}
scope.pagedata.openLocation=function(item){
	wx.openLocation({
	latitude: item.lat_lng.lat, // 纬度，浮点数，范围为90 ~ -90
	longitude: item.lat_lng.lng, // 经度，浮点数，范围为180 ~ -180。
		name: item.province+item.city+item.district, // 位置名
		address: item.address, // 地址详情说明
		scale: 20, // 地图缩放级别,整形值,范围从1~28。默认为最大
		infoUrl: '', // 在查看位置界面底部显示的超链接,可点击跳转
		success:function(){
			//alert(1111);
		}
	});
}
if(scope.pagedata.pluginset.dingwei!=1){
	window.scope.location(function(res){
			scope.pagedata.post.address = res.address;
			scope.pagedata.get_store(res.lat_lng.lat,res.lat_lng.lng);
	});
}
scope.pagedata.settime=function(index,id){
	var timeid=id?id:scope.pagedata.serve_time[index].id;
	var isselecttimes=scope.pagedata.isselecttimes;
	var isadd=false;
	var price=0;
	console.log(timeid);
	scope.duoxuans(timeid,scope.pagedata.post,'timeids');
	isselecttimes=isselecttimes?isselecttimes:[];
	for(var i=0;i<isselecttimes.length;i++){
		if(isselecttimes[i].selectid==timeid){
			console.log(isselecttimes[i].selectid+'~~'+timeid);
			isadd=true;
			//isselecttimes.splice(i,1);
		}else{
			price +=parseInt(isselecttimes[i].fee);
		}
	}
	if(!isadd){
		uptime={
			'selectid':timeid,
			'times':scope.pagedata.serve_time[index].times,
			'fee':scope.pagedata.serve_time[index].fee,
			'is_ban':scope.pagedata.post.is_ban
		}
		scope.pagedata.isselecttimes.push(uptime);
		price +=parseInt(scope.pagedata.serve_time[index].fee);
	}
	scope.pagedata.post.price=price;
	scope.pagedata.post.totalprice=price*scope.pagedata.post.total;
	scope.$evalAsync();
}
scope.pagedata.check_buy=function(){
	var serve_id=scope.pagedata.serve.id
	var store_id=scope.pagedata.post.store_id
	var packageid=scope.pagedata.post.packageid
	var timeids=scope.pagedata.post.timeids
	var dayid=scope.pagedata.post.dayid
	var plate_id=scope.pagedata.post.plate_id
	var is_ban=scope.pagedata.post.is_ban
	console.log(is_ban);
	scope.get('jy_qiuyuyue/server/check_buy/plate_id='+plate_id+'&serve_id='+serve_id+'&store_id='+store_id+'&timeids='+timeids+'&dayid='+dayid+'&is_ban='+is_ban,function(res){});
}
</script>
<script type="text/javascript">
scope.pagedata.post.dayid = 0;
scope.pagedata.post.packageid = 0;
//scope.pagedata.post.timeid = 0;
</script>
<script>
require(['bootstrap', 'hammer'], function($, Hammer){
		$('#carousel-container').carousel();
		var mc = new Hammer($('#carousel-container').get(0));
		mc.on("panleft", function(ev) {
			$('#carousel-container').carousel('next');
		});
		mc.on("panright", function(ev) {
			$('#carousel-container').carousel('prev');
		});
});
scope.pagedata.getdata = function(){
		scope.post_json('jy_qiuyuyue/server/serve_time/',scope.pagedata.post,function(data){
			if(data.success == 1){
					scope.pagedata.isselecttimes=[];
					scope.pagedata.post.timeids='';
					scope.pagedata.post.price='0.00';
					scope.pagedata.serve_time = data.serve_time;
					scope.$evalAsync();
			}
		});
}
scope.pagedata.getdata();
</script>